package org.lds.hotkey.worker.controller;

import org.lds.hotkey.client.remote.Client;
import org.lds.hotkey.common.model.dto.ResultDTO;
import org.lds.hotkey.console.remote.model.BatchReceiveHotkeyRequest;
import org.lds.hotkey.console.remote.model.ReceiveHotkeyRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
@RequestMapping("/test/api")
public class TestController {
    @RequestMapping("/client/hotkey")
    public ResultDTO<Boolean> hotkey() {
        String address = "127.0.0.1:9091";
        ReceiveHotkeyRequest request = ReceiveHotkeyRequest.builder()
                .ruleId(0L)
                .key("sso:cache:client")
                .duration(10)
                .build();
        return Client.receiveHotkey(address, BatchReceiveHotkeyRequest.builder().requests(Arrays.asList(request)).build());
    }
}
